import types from './types'
const mutations = {
	//订单tab权限
	[types.UPDATE_ORDER_TAB](state, payload) {
		let datas = []
		let idxs = state.roles[payload.user_type];
		if(!!idxs && idxs.length > 0) {
			idxs.forEach((v) => {
				datas.push(state.orderTitleList[v])
			});
		}
		state.order_tab = datas
	},
	// 更新参数
	[types.UPDATE_PARAMS](state, payload) {
		Object.assign(state.params, payload)
	},

	// 设置 ORDERS
	[types.SET_ORDERS](state, payload) {
		state.orders = payload.orders
		state.total = payload.total
	},

	// 更新分页
	[types.UPDATE_PAGINATE](state, payload) {
		Object.assign(state.paginate, payload)
	},

	// 获取师傅
	[types.SET_MASTERS](state, payload) {
		state.masters = payload
	},

	// 获取品牌
	[types.SET_COMPANIES](state, payload) {
		state.companies = payload
	},

	// 设置 order
	[types.SET_ORDER](state, payload) {
		state.order = payload
	},

	// 设置 materials
	[types.SET_MATERIALS](state, payload) {
		state.materials = payload
	},

	// 设置审核人列表
	[types.SET_AUDIT_USERS](state, payload) {
		// console.log('payload', payload)
		state.audit_users = payload
	}
}

export default mutations